package com.dinzeer.slashblade_useful_addon.events;

import com.dinzeer.slashblade_useful_addon.config.Config;
import mods.flammpfeil.slashblade.item.ItemSlashBlade;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class RandomDamge {









    @SubscribeEvent(priority = EventPriority.LOWEST)
    public static void dohurt(LivingHurtEvent event){
        if (Config.DAMAGE_RANDOM.get()) {
            if (event.getSource().getEntity() instanceof Player player) {
                if (player.getMainHandItem().getItem() instanceof ItemSlashBlade) {

                    event.setAmount(player.getRandom().nextInt(1, (int) (event.getAmount() * 2)));
                }
            }
        }
    }
}
